import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

// 提示dialog
class ExitTips extends StatelessWidget {
  const ExitTips({
    required this.func,
    super.key, this.content, this.title,
  });

  // 标题
  final String? title;
  
  final String? content;

  final Function(bool b) func;

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      child: Container(
        width: 300.w,
        height: 210.w,
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.all(Radius.circular(20.w)),
          gradient: const LinearGradient(
              //渐变位置
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
              //渐变颜色[始点颜色, 结束颜色]
              colors: [
                Color(0xffE7EAFF),
                Color(0xffffffff),
                Color(0xffffffff),
                Color(0xffffffff),
              ]),
        ),
        child: Stack(
          alignment: Alignment.center,
          children: [
            Container(
                padding: EdgeInsets.symmetric(horizontal: 30.w),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  children: [
                    Text(
                      title ?? '提示',
                      style: TextStyle(
                          color: Colors.black,
                          fontSize: 18.sp,
                          fontWeight: FontWeight.bold),
                    ),
                    Text(
                       content ?? '返回后所填信息不支持继续编辑，确定退出？',
                      style: TextStyle(
                        color: Colors.black,
                        fontSize: 14.sp,
                      ),
                    ),
                    SizedBox(
                      width: 270.w,
                      height: 40.w,
                      child: ElevatedButton(
                        style: ButtonStyle(
                          backgroundColor: MaterialStateProperty.all(
                              const Color(0xff5C6DFF)),
                        ),
                        child: Text(
                          '确定',
                          style:
                              TextStyle(fontSize: 16.sp, color: Colors.white),
                        ),
                        onPressed: () {
                          func(true);
                          Navigator.pop(context);
                        },
                      ),
                    )
                  ],
                )),
            Positioned(
                top: 8,
                right: 8,
                child: IconButton(
                  icon: Container(
                    width: 30.w,
                    height: 30.w,
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(15.w)),
                    ),
                    child: Icon(
                      Icons.close,
                      color: Colors.grey,
                      size: 21.w,
                    ),
                  ),
                  onPressed: () {
                    func(false);
                    Navigator.pop(context);
                  },
                ))
          ],
        ),
      ),
    );
  }
}
